﻿using System;

namespace Yoozoo.Modules.Download
{
    public class DownloadInfo : IComparable<DownloadInfo>
    {
        public string Url;
        public string Path;
        public ulong TotalSize;
        public ulong CurrentSize;
        public string ErrorMessage;
        public int Priority;
        public Action<bool> OnFinished;
        public DownloadState State;
        public UnityWebRequestDownload UnityWebRequestDownload;
        public PreAllocatedBuffer Buffer;

        public int CompareTo(DownloadInfo other)
        {
            return -Priority.CompareTo(other.Priority);
        }

        public void Reset()
        {
            Url = null;
            Path = null;
            TotalSize = 0;
            CurrentSize = 0;
            ErrorMessage = null;
            Priority = 0;
            OnFinished = null;
            State = DownloadState.None;
            UnityWebRequestDownload = null;
            Buffer = null;
        }
    }
}
